package com.itheima.controller;

import com.itheima.pojo.User;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import sun.net.util.IPAddressUtil;

import javax.jws.soap.SOAPBinding;
import java.util.Arrays;
import java.util.Date;

@Controller
public class ParamController {

    /*@ResponseBody
    //普通参数传递1
    @RequestMapping("/putong1")
    public String commonParm1(String name, int age) {
        System.out.println("普通传递参数 name==" + name);
        System.out.println("普通传递参数 age==" + age);
        return "{'moudle':'cpmmon param'}";
    }*/

    /*//形式参数传递2
    @ResponseBody
    @RequestMapping("/putong2")
    public String commonParm2(
            //形参注解
            @RequestParam(value = "name1", required = false, defaultValue = "张三") String name,
            @RequestParam("age1") int age) {
        System.out.println(name);
        System.out.println(age);
        return "{'info':'haha'}";
    }*/

   /* //pojo类参数，请流参数与形参对象中的属性对应即可完成参数传递
    @ResponseBody
    @RequestMapping("/pojo")
    public String pojoparm(User user){
        System.out.println("pojo参数传递=="+user);
        return "{'modole':'pojo param'}";
    }*/

    /*//嵌套pojo类型参数 pojo对象中包含pojo对象
    @ResponseBody
    @RequestMapping("/pojocontain")
    public String pojocontainpojoparam(User user){
        System.out.println("pojo嵌套pojo参数传递 user=="+user);
        return "{'module':'pojo contain pojo param'}";
    }*/
    /*//数组类型参数：同名请求参数可以直接映射到对应名称的形参数组对象中
    @RequestMapping("/arrayparam")
    @ResponseBody
    public String arrayparam(String[] likes){
        System.out.println("数组参数传递 likes"+ Arrays.toString(likes));
        return "{'module':'array param'}";
    }*/

    /*//日期类型参数传递
    @RequestMapping("/date")
    @ResponseBody
    public String dataparm(Date date,
                           @DateTimeFormat(pattern = "yyyy-MM-dd") Date date1,
                           @DateTimeFormat(pattern = "yyyy/MM/dd HH:mm:ss")Date date2){
        System.out.println("参数传递yyyy-MM-dd date=="+date1);
        System.out.println("参数传递yyyy/MM/dd HH:mm:ss date=="+date2);
        return "{'module':'data param'}";
    }*/



}
